<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>

<body>
  <script>
    let arr = [
      {
        "id": 1,
        "createTime": "2023-05-23T09:38:03.000+00:00",
        "updateTime": "2023-05-23T09:38:03.000+00:00",
        "remark": null,
        "deleted": false,
        "dataSource": "档案中心",
        "stationId": 212,
        "deviceId": 654,
        "partsId": 2789,
        "isRelatedToDevice": true,
        "partsModelId": null,
        "partsCode": "乌拉拉验证的",
        "parentId": 0,
        "partsName": "颠三倒四多的",
        "children": null,
        "supplier": null,
        "model": null,
        "materialCode": null
      },
      {
        "id": null,
        "createTime": null,
        "updateTime": null,
        "remark": null,
        "deleted": false,
        "dataSource": "档案中心",
        "stationId": 212,
        "deviceId": 654,
        "partsId": 1944,
        "isRelatedToDevice": false,
        "partsModelId": null,
        "partsCode": "MDA",
        "parentId": 0,
        "partsName": "风轮系统",
        "children": [
          {
            "id": 2,
            "createTime": "2023-05-24T09:51:30.000+00:00",
            "updateTime": "2023-05-24T09:51:30.000+00:00",
            "remark": null,
            "deleted": false,
            "dataSource": "档案中心",
            "stationId": 212,
            "deviceId": 654,
            "partsId": 2759,
            "isRelatedToDevice": true,
            "partsModelId": null,
            "partsCode": "哇哈哈",
            "parentId": 1944,
            "partsName": "MDA",
            "children": null,
            "supplier": null,
            "model": null,
            "materialCode": null
          }
        ],
        "supplier": null,
        "model": null,
        "materialCode": null
      }
    ]
    let result = arr.filter(item=>item.isRelatedToDevice === true).map(item=>item.partsId)
    console.log(result);
  </script>
</body>

</html>